Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

278
Visualizações
Mysql "Select mod(col1, 10) ... " generates bigint. How to make it to be int type

I have following code

String sql = "(select mod_col, 1 as count_col from ( " +
                    "select mod(col1, 10) as mod_col " +
                    "from table1 c " +
                    "where c.col2 = 1) temp " +
                    "group by mod_col, count_col ) as temp2";

DataFrame df = getDSEDataFrame(sql);

Note that the col1 is defined in mysql with type int(11) NOT NULL.

However, when I check the df, the mod_col has the correct value as a bigint. This cause an exception java.math.BigDecimal cannot be cast to java.lang.Integer for my following code

        List<Row> col1List = df.collectAsList();

        for (Row r : col1List) {
             Integer col1Val = r.getAs("mod_col");  // exception thrown here
        }

Is there any way in above sql that I can force it return an integer instead of a big integer?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda